package com.his.service;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.his.common.PageParam;
import com.his.common.Rsp;
import com.his.entity.Log;
import com.his.mapper.LogMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class LogService {
    @Resource
    private LogMapper logMapper;

    public  Rsp getAll(PageParam<Log> pageParam) {
        PageHelper.startPage(pageParam.getPageNum(), pageParam.getPageSize());
        //执行排序
        for (int i = 0; i < pageParam.getOrderParams().length; i++) {
            PageHelper.orderBy(pageParam.getOrderParams()[i]);
        }
        List<Log> list = logMapper.getAll(pageParam.getModel());
        return Rsp.success(new PageInfo<>(list));
    }

    public Rsp del(Integer id) {
        return logMapper.deleteById(id) > 0 ? Rsp.success(null) : Rsp.fail().msg("删除失败");
    }
}
